package com.ruoyi.activiti;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.Deployment;

/**
 * 流程部署---将定义好的内容注册到数据库表中
 */
public class ActivitiDeployment {
    //流程定义部署
    public static void main(String[] args) {
        //1.创建ProcessEngine对象
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        System.out.println("....开始部署流程...");

        //2.得到RepositoryService实例
        RepositoryService repositoryService = processEngine.getRepositoryService();
        //3.进行部署
        //yanruTODO:我尝试了一下，假如没有执行 buildProcessEngine()没有先生成流程配置，但是我直接进行了deploy部署操作，结果就是数据库也能生成所有配置文件
        Deployment deploy = repositoryService.createDeployment()
                .addClasspathResource("diagram/holiday.bpmn")
                .addClasspathResource("diagram/holiday.png")
                .name("请假申请的流程")
                .key("宝塔镇河妖")
                .deploy();
        //4.输出一些部署的信息
        System.out.println("部署对象的id:"+deploy.getId());
        System.out.println("部署对象的key:"+deploy.getKey());
        System.out.println("部署对象的name:"+deploy.getName());
        System.out.println("部署完毕.....");
    }
}
